package dao;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtil {
	private static SessionFactory sf;

	static {
		try {
			sf = new AnnotationConfiguration().configure().buildSessionFactory();
		} catch (Throwable tr) {
			tr.printStackTrace();
			throw new ExceptionInInitializerError("Session Factory building failed.");
		}
	}

	public static final SessionFactory getSessionFactory() {
		return sf;
	}
	
	public static final void shutdown() {
		getSessionFactory().close();
	}

}
